package com.szbber.medical.viewmodel.fragment

import android.content.Context
import android.graphics.Color
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.MutableLiveData
import androidx.recyclerview.widget.LinearLayoutManager
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.szbber.commen.api.Repository
import com.szbber.commen.api.launch
import com.szbber.commen.base.BaseViewModel
import com.szbber.commen.bean.AddCareLabelBean
import com.szbber.commen.bean.CareLevelListBean
import com.szbber.commen.bean.NurseLevelListBean
import com.szbber.medical.R
import com.szbber.medical.databinding.ItemNurselevelBinding
import kotlinx.android.synthetic.main.fragment_nurselevel_setting.*

class NurseLabelSettingViewModel : BaseViewModel() {

    var careLevelListBean = MutableLiveData<CareLevelListBean>()

    fun getCareLevelList(context: Context?) = launch(context, {
        careLevelListBean.value = Repository.getCareLevelList(context)
    })


    fun getEditCareLevel(context: Context?,
        id: String,
        labelName: String?,
        fontColor: String?,
        bgColor: String?) = launch(context, {
        val queue =
            arrayOf("id", id, "labelName", labelName, "fontColor", fontColor, "bgColor", bgColor)
        Repository.getEditCareLevel(context, *queue)
        getCareLevelList(context)
    })

    fun addNurseLevelLabel(context: Context?, addCareLabelBean: AddCareLabelBean?)= launch(context,{
        val queue = arrayOf("bgColor", addCareLabelBean?.bgColor,"fontColor", addCareLabelBean?.fontColor,"labelCat", addCareLabelBean?.labelCat, "levelName", addCareLabelBean?.labelName)
        Repository.addNurseLevelLabel(context,*queue)
        getCareLevelList(context)
    })

    fun deleteNurseLevelLabel(context: Context?, labeleId:String? ) = launch(context, {
        val queue = arrayOf("labeleId", labeleId)
        Repository.deleteNurseLevelLabel(context, *queue)
        getCareLevelList(context)
    })

}